<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        h1~p {
            font-weight: bold;
            background-color: #333;
            color: #fff;
            padding: .5em;
        }
    </style>

    <style>
        p~span {
            color: red;
        }
    </style>
</head>

<body>

    <!-- 关系选择器 -->
    <!-- https://developer.mozilla.org/zh-CN/docs/Learn/CSS/Building_blocks/Selectors/Combinators -->

    <!-- 通用兄弟 -->
    <!-- https://developer.mozilla.org/zh-CN/docs/Learn/CSS/Building_blocks/Selectors/Combinators#%E9%80%9A%E7%94%A8%E5%85%84%E5%BC%9F -->
    <!-- 如果你想选中一个元素的兄弟元素，即使它们不直接相邻，你还是可以使用通用兄弟关系选择器（~）。 -->
    <!-- 通用兄弟选择器 -->
    <!-- https://developer.mozilla.org/zh-CN/docs/Web/CSS/General_sibling_combinator -->
    <!-- 兄弟选择符，位置无须紧邻，只须同层级，A~B 选择A元素之后所有同层级B元素。 -->

    <article>
        <h1>A heading</h1>
        <p>I am a paragraph.</p>
        <div>I am a div</div>
        <p>I am another paragraph.</p>
    </article>

    <hr>

    <div>
        <span>This is not red.</span>
        <p>Here is a paragraph.</p>
        <code>Here is some code.</code>
        <span>And here is a span.</span>
        <br>
        <code>Here is some code.</code>
        <span>And here is a span.</span>
    </div>
</body>

</html>